<template>
    <div class="m-25 mt-65">
        <div class="normal-box-mod">
            <!-- <div class="normal-box-hd clearfix">
                <div class="normal-box-title">
                    <div class="decorate-square"></div>
                    <h2>回收站点列表</h2>
                </div>
            </div> -->
            <div class="normal-box-bd">
                <div class="normal-list-page-mod">
                    <div class="mb-2"
                         style="margin-bottom:40px">
                        <Button custom-icon="iconfont icon-fangkuai2"
                                size="small"
                                type="primary"
                                @click="showCreateModal"
                                style="float:right">
                            新建网点
                        </Button>
                        <!-- action:上传的地址 -->
                        <Upload multiple
                                style="float:right"
                                action="//jsonplaceholder.typicode.com/posts/">
                            <Button :loading="reading"
                                    icon="ios-cloud-upload-outline"
                                    style="margin-right: 50px">上传Excel文件</Button>
                        </Upload>
                        <Col span="4"
                             class="mr-10">
                        <Input v-model="queryData.siteName"
                               placeholder="回收网点名称"
                               clearable />
                        </col>

                        <Button type="primary"
                                custom-icon="iconfont icon-chaxun"
                                size="small"
                                @click="iQueryData">查找</Button>
                    </div>
                    <div class="normal-list-page-bd">
                        <Table :columns="columns"
                               :data="list.data"
                               border></Table>
                    </div>
                    <Page :total="queryData.totalRecord"
                          :current="queryData.page"
                          :page-size="queryData.limit"
                          show-total
                          show-elevator
                          show-sizer
                          @on-change="changePage"
                          @on-page-size-change="changePageSize"
                          style="text-align: center;" />
                </div>
            </div>
            <!-- 新建-->
            <Modal v-model="level1Modal.modal1"
                   :title="level1Modal.title"
                   @on-ok="postData"
                   @on-cancel="cancel"
                   height="600px">
                <Form :model="level1Modal.formData"
                      :rules="level1Modal.ruleValidate"
                      ref="systemFro"
                      :label-width="130">

                    <!-- <FormItem label="回收企业ID"
                              prop="companyId">
                        <Input v-model="level1Modal.formData.companyId"
                               placeholder="请输入企业ID"
                               style="width:350px;"></Input>
                    </FormItem> -->
                    <FormItem label="回收企业名称"
                              prop="companyName">
                        <Input v-model="level1Modal.formData.companyName"
                               placeholder="请输入企业名称"
                               style="width:350px;"
                               disabled></Input>
                    </FormItem>
                    <!-- <FormItem label="回收企业名称"
                              prop="companyId">
                        <Select @on-change="changeCompanyCode"
                                clearable
                                label-in-value="true"
                                v-model="level1Modal.formData.companyId"
                                style="width:350px;">
                            <Option v-for="item in level1Modal.companyOptions"
                                    :value="item.value"
                                    :key="item.value">{{ item.label }}</Option>
                        </Select>
                    </FormItem> -->
                    <!-- <FormItem label="回收企业名称11111111"
                              v-if="level1Modal.companyNameFlag"
                              prop="companyId">
                        <Select @on-change="changeCompanyCode"
                                clearable
                                label-in-value="true"
                                v-model="level1Modal.formData.companyId"
                                style="width:350px;">
                            <Option v-for="item in level1Modal.companyOptions"
                                    :value="item.value"
                                    :key="item.value">{{ item.label }}</Option>
                        </Select>
                    </FormItem> -->
                    <FormItem label="回收网点名称"
                              prop="siteName">
                        <Input v-model="level1Modal.formData.siteName"
                               placeholder="请输入网点名称"
                               style="width:350px;"></Input>
                    </FormItem>
                    <FormItem label="回收网点地址"
                              prop="siteAddress">
                        <Input v-model="level1Modal.formData.siteAddress"
                               placeholder="请输入回收网点地址"
                               style="width:350px;"></Input>
                    </FormItem>
                    <FormItem label="联系人"
                              prop="contacts">
                        <Input v-model="level1Modal.formData.contacts"
                               placeholder="请输入联系人"
                               style="width:350px;"></Input>
                    </FormItem>
                    <FormItem label="联系电话"
                              prop="phone">
                        <Input v-model="level1Modal.formData.phone"
                               placeholder="请输入联系电话"
                               style="width:350px;"></Input>
                    </FormItem>
                    <FormItem label="手机号码"
                              prop="mobile">
                        <Input v-model="level1Modal.formData.mobile"
                               placeholder="请输入手机号码"
                               style="width:350px;"></Input>
                    </FormItem>
                    <FormItem label="状态"
                              prop="state">
                        <Select @on-change="changeCode"
                                clearable
                                label-in-value="true"
                                v-model="level1Modal.formData.state"
                                style="width:350px;">
                            <Option v-for="item in level1Modal.options"
                                    :value="item.value"
                                    :key="item.value">{{ item.label }}</Option>
                        </Select>

                    </FormItem>
                    <!-- <FormItem label="地区">
                        <Col span="24"
                             class="mr-10">
                        <sele @ProvinceData="childByValue"
                              massage="1"
                              :key="forceRefresh"></sele>
                        </Col>
                    </FormItem> -->
                    <FormItem label="地区"
                              v-if="addressFlag == true">
                        <Col span="24"
                             class="mr-10">
                        <sele @ProvinceData="childByValue"
                              massage="1"
                              :key="forceRefresh"></sele>
                        </Col>
                    </FormItem>
                    <FormItem label="地区"
                              v-if="addressFlag == false">
                        <Col span="24"
                             class="mr-10">
                        <sele @ProvinceData="childByValue"
                              massage="1"
                              :address='address'
                              :key="forceRefresh"></sele>
                        </Col>
                    </FormItem>
                </Form>
            </Modal>

            <!-- 回收网点管理员弹层 -->
            <Modal v-model="levelSiteModal.modal"
                   :title="levelSiteModal.title"
                   fullscreen
                   height="600px">
                <siteAdmin :siteData="levelSiteModal.formData"
                           v-if="levelSiteModal.flag"></siteAdmin>
            </Modal>
            <!-- 回收网点地址弹层 -->
            <Modal v-model="levelSiteLocaltionModal.modal"
                   :title="levelSiteLocaltionModal.title"
                   fullscreen
                   height="600px">
                <siteLocaltion :siteLocaltionData="levelSiteLocaltionModal.formData"
                               v-if="levelSiteLocaltionModal.flag"></siteLocaltion>
            </Modal>

            <!-- 上传经纬度 -->
            <Modal v-model="uploadLatitudeAndLongitudeModal.modal"
                   :title="uploadLatitudeAndLongitudeModal .title"
                   @on-ok="postLatLogData"
                   @on-cancel="cancel"
                   height="600px">
                <Form :model="uploadLatitudeAndLongitudeModal.formData"
                      :rules="uploadLatitudeAndLongitudeModal.ruleValidate"
                      ref="systemFro1"
                      :label-width="130">

                    <FormItem label="经度"
                              prop="lng">
                        <Input v-model.trim="uploadLatitudeAndLongitudeModal.formData.lng"
                               placeholder="请输入经度"
                               style="width:350px;"></Input>
                    </FormItem>

                    <FormItem label="纬度"
                              prop="lat">
                        <Input v-model.trim="uploadLatitudeAndLongitudeModal.formData.lat"
                               placeholder="请输入纬度"
                               style="width:350px;"></Input>
                    </FormItem>
                </Form>
            </Modal>
        </div>
    </div>
</template>
<script>
import sele from '@/view/test/city.vue'
import SiteApi from '@/api/recycle/site.js'
import siteAdmin from './components/siteAdmin.vue'
import siteLocaltion from './components/siteLocaltion.vue'
import cityFormApi from '@/api/base_sys/gcDispenser.js'
export default {
	props: ['companyData'],
	// 必须引入 注册 否则不生效
	components: {
		sele,
		siteAdmin,
		siteLocaltion
	},
	data() {
		return {
			address: '',
			addressFlag: false,
			forceRefresh: '', //强制刷新子组件
			queryData: {
				page: 1,
				limit: 10,
				// companyId: '',
				siteName: ''
				// provId: '',
				// cityId: '',
				// distId: '',
				// strtId: '',
				// commId: '',
				// comminId: ''
				// companyName: ''
			},
			queryCompanyData: {
				companyName: '',
				provId: '',
				cityId: '',
				distId: '',
				strtId: '',
				commId: '',
				comminId: ''
			},
			columns: [
				{
					type: 'selection',
					width: 60,
					align: 'center'
				},
				{
					title: 'id',
					key: 'id',
					align: 'center'
				},
				// {
				// 	title: '回收企业id',
				// 	key: 'companyId',
				// 	align: 'center'
				// },
				{
					title: '回收企业名称',
					key: 'companyName',
					align: 'center'
				},
				{
					title: '回收网点名称',
					key: 'siteName',
					align: 'center'
				},
				{
					title: '回收网点地址',
					key: 'siteAddress',
					align: 'center'
				},
				{
					title: '联系人',
					key: 'contacts',
					align: 'center'
				},
				{
					title: '联系电话',
					key: 'phone',
					align: 'center'
				},
				{
					title: '手机号码',
					key: 'mobile',
					align: 'center'
				},
				{
					title: '状态',
					key: 'state',
					align: 'center',
					render: (create, params) => {
						let s = params.row.state
						let color, text
						if (s == 1) {
							color = '#5ed71a'
							text = '正常'
						} else {
							color = '#d72c23'
							text = '停止运行'
						}
						return create(
							'div',
							{
								style: {
									color: color,
									borderRadius: '20px'
								}
							},
							text
						)
					}
				},
				{
					title: '创建时间',
					key: 'createTime',
					align: 'center'
				},
				{
					title: '更新时间',
					key: 'updateTime',
					align: 'center'
				},
				/** 自动生成结束 */
				{
					title: '操作',
					align: 'center',
					minWidth: 150,
					render: (h, params) => {
						// 动态渲染组件
						return h('div', { class: 'action-group' }, [
							h(
								'Tooltip',
								{
									props: {
										placement: 'left',
										content: '上传经纬度'
									},
									style: {
										cursor: 'pointer'
									}
								},
								[
									h(
										'Button',
										{
											props: {
												type: 'success',
												size: 'small'
											},
											style: {
												marginRight: '5px',
												padding: '1px 2px'
											},
											on: {
												click: () => {
													this.showUploadLatitudeAndLongitudeModal(
														params.row
													)
												}
											}
										},
										[
											h('Icon', {
												props: {
													type: 'md-add-circle',
													size: 18
												}
											})
										]
									)
								]
							),
							h(
								'Tooltip',
								{
									props: {
										placement: 'left',
										content: '回收网点管理员'
									},
									style: {
										cursor: 'pointer'
									}
								},
								[
									h(
										'Button',
										{
											props: {
												type: 'info',
												size: 'small'
											},
											style: {
												marginRight: '5px',
												padding: '1px 2px'
											},
											on: {
												click: () => {
													this.showSiteModal(
														params.row
													)
												}
											}
										},
										[
											h('Icon', {
												props: {
													type: 'md-contact',
													size: 18
												}
											})
										]
									)
								]
							),
							h(
								'Tooltip',
								{
									props: {
										placement: 'left',
										content: '编辑'
									},
									style: {
										cursor: 'pointer'
									}
								},
								[
									h(
										'Button',
										{
											props: {
												type: 'primary',
												size: 'small'
											},
											style: {
												marginRight: '5px',
												padding: '1px 2px'
											},
											on: {
												click: () => {
													this.showUpdateModal(
														params.row
													)
												}
											}
										},
										[
											h('Icon', {
												props: {
													type:
														' iconfont icon-bianjisekuai',
													size: 18
												}
											})
										]
									)
								]
							),

							h(
								'Tooltip',
								{
									props: {
										placement: 'right',
										content: '删除'
									},
									style: {
										cursor: 'pointer'
									}
								},
								[
									h(
										'Button',
										{
											props: {
												type: 'error',
												size: 'small'
											},
											style: {
												marginRight: '5px',
												padding: '1px 2px'
											},
											on: {
												click: () => {
													this.delData(params.row)
												}
											}
										},
										[
											h('Icon', {
												props: {
													type:
														' iconfont icon-shanchusekuai',
													size: 18
												}
											})
										]
									)
								]
							)
						])
						// }
					}
				}
			],
			list: {
				data: [
					// {
					// 	id: 1,
					// 	siteName: '庆春回收网点',
					// 	siteAddress: '庆春路238-1号',
					// 	companyId: 5,
					// 	companyName: '杭州哈哈哈再生资源回收公司',
					// 	contacts: '王珍',
					// 	mobile: '13566677788',
					// 	phone: '0571-88012465',
					// 	state: 2,
					// 	provId: 330000,
					// 	cityId: 330100,
					// 	distId: 330110,
					// 	strtId: 3397,
					// 	commId: 21068,
					// 	comminId: 21069
					// }
				]
			},
			level1Modal: {
				modal1: false,
				title: '',
				formData: {
					siteName: '',
					siteAddress: '',
					companyId: '',
					companyName: '',
					contacts: '',
					mobile: '',
					phone: '',
					state: 1
					// provId: '',
					// cityId: '',
					// distId: '',
					// strtId: '',
					// commId: '',
					// comminId: ''
				},
				ruleValidate: {
					companyId: [
						{
							required: true,
							message: '回收企业名称不能为空'
						}
					],
					companyName: [
						{
							required: true,
							message: '请输入企业名称',
							trigger: 'blur'
						}
					],
					siteName: [
						{
							required: true,
							message: '请输入回收网点名称',
							trigger: 'blur'
						}
					],
					siteAddress: [
						{
							required: true,
							message: '请输入回收网点地址',
							trigger: 'blur'
						}
					],
					contacts: [
						{
							required: true,
							message: '请输入联系人',
							trigger: 'blur'
						}
					],
					mobile: [
						{
							required: true,
							message: '请输入手机号码',
							trigger: 'blur'
						},
						{
							pattern: /^1[3456789]\d{9}$/,
							message: '手机号码格式不正确',
							trigger: 'blur'
						}
					],
					state: [{ required: true, message: '请选择状态' }],
					area: [
						{
							required: true,
							type: 'array',
							min: 1,
							message: '请选择省市区'
						}
					]
				},
				options: [
					{
						value: 1,
						label: '正常'
					},
					{
						value: 2,
						label: '停止运行'
					}
				],
				companyOptions: [
					// {
					// 	value: 4,
					// 	label: '杭州拱墅区再生资源回收有限公司'
					// },
				],
				recyclingCompanyNameFlag: false,
				companyNameFlag: false
			},
			levelSiteModal: {
				modal: false,
				title: '回收网点管理员',
				formData: {},
				flag: false
			},
			levelSiteLocaltionModal: {
				modal: false,
				title: '回收网点定位',
				formData: {},
				flag: false
			},
			addressFlag: true,
			uploadLatitudeAndLongitudeModal: {
				modal: false,
				title: '上传经纬度',
				formData: {},
				flag: false,
				ruleValidate: {
					lng: [
						{
							required: true,
							message: '经度不能为空'
						},
						{
							pattern: /^-?((1[0-7]|[1-9])?\d(\.\d+)?|180(\.0+)?)$/,
							message: '请输入正确的经度，范围:-180~180'
							// trigger: 'blur'
						}
					],
					lat: [
						{
							required: true,
							message: '纬度不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^-?([1-8]?\d(\.\d+)?|90(\.0+)?)$/,
							message: '请输入正确的纬度，范围:-90~90'
							// trigger: 'blur'
						}
					]
				}
			}
		}
	},
	// 监听companyData是否变化,变化重新加载数据
	watch: {
		companyData(newValue, oldValue) {
			if (newValue) {
				this.queryData.page = 1
				this.queryData.siteName = ''
				this.getPageList()
			}
		}
	},

	mounted() {
		this.getPageList()
		this.getCompanyList()
	},
	created() {},
	computed: {},
	methods: {
		getProvince(data, comminid) {
			console.log(comminid, 'comminid')
			cityFormApi.getDown(data).then(res => {
				let that = this
				let province = res.data
				console.log(res.data, 'res.data')
				// for (let i = 0; i < province.length; i++) {
				// 	let wzpz = province[i]
				// 	wzpz.value = wzpz.id
				// 	// wzpz.value = wzpz.name

				// 	wzpz.label = wzpz.name
				// 	wzpz.loading = false
				// 	wzpz.children = []
				// 	that.newSbType.push(wzpz)
				// }
				var arr = res.data
				var result = arr.find(function(item) {
					return item.id == comminid
				})
				console.log(result, 'result')
				var addRess = {
					value: result.id,
					label: result.name
				}
				this.address = addRess
				console.log(this.address, '1111111111')
			})
		},
		// 上传经纬度
		showUploadLatitudeAndLongitudeModal(row) {
			console.log(row, 'row1111111111')
			this.uploadLatitudeAndLongitudeModal.modal = true
			this.uploadLatitudeAndLongitudeModal.title = '上传经纬度'
			this.uploadLatitudeAndLongitudeModal.formData = {
				id: row.id,
				lng: row.lng,
				lat: row.lat
			}
		},
		postLatLogData() {
			let that = this
			this.$refs['systemFro1'].validate(valid => {
				if (valid) {
					if (that.uploadLatitudeAndLongitudeModal.formData.id) {
						console.log(this.level1Modal.formData, '3333333333333')
						console.log(
							that.uploadLatitudeAndLongitudeModal.formData,
							'777777777777777'
						)
						SiteApi.update(
							that.uploadLatitudeAndLongitudeModal.formData
						).then(res => {
							if (res.code == 0) {
								that.$Message.success('上传成功')
								this.$refs['systemFro1'].resetFields()
								that.uploadLatitudeAndLongitudeModal.formData = {}

								return
							} else {
								that.$Message.error(res.message)
							}
						})
					}
				} else {
					this.$Message.error('请填写完整的表单项')
				}
			})
		},
		//判断对象是否为空
		isEmptyObject(obj) {
			for (let key in obj) {
				return false
			}
			return true
		},
		// 查询按钮地区赋值
		childByValue1(data) {
			this.queryData.provId = data.provid || ''
			this.queryData.cityId = data.cityid || ''
			this.queryData.distId = data.distid || ''
			this.queryData.strtId = data.strtid || ''
			this.queryData.commId = data.commid || ''
			this.queryData.comminId = data.comminid || ''
		},
		// 查询
		iQueryData() {
			console.log(this.queryData, 'queryData')
			this.getPageList()
		},
		showCreateModal() {
			this.addressFlag = true
			this.level1Modal.modal1 = true
			this.level1Modal.title = '新建回收站点'
			this.level1Modal.formData.provId = this.companyData.provId
			this.level1Modal.formData.cityId = this.companyData.cityId
			this.level1Modal.formData.distId = this.companyData.distId
			this.level1Modal.formData.strtId = this.companyData.strtId
			this.level1Modal.formData.commId = this.companyData.commId
			this.level1Modal.formData.comminId = this.companyData.comminId
			this.level1Modal.formData.companyId = this.companyData.id
			this.level1Modal.formData.companyName = this.companyData.companyName
			this.queryCompanyData.provId = this.companyData.provId
			this.queryCompanyData.cityId = this.companyData.cityId
			this.queryCompanyData.distId = this.companyData.distId
			this.queryCompanyData.strtId = this.companyData.strtId
			this.queryCompanyData.commId = this.companyData.commId
			this.queryCompanyData.comminId = this.companyData.comminId
			console.log(
				this.queryCompanyData,
				'22222222222222222222222222222222222222222222222222'
			)
			if (
				this.queryCompanyData.provId &&
				this.queryCompanyData.cityId &&
				this.queryCompanyData.distId &&
				this.queryCompanyData.strtId &&
				this.queryCompanyData.commId &&
				this.queryCompanyData.comminId
			) {
				console.log('111111111')
				// this.level1Modal.recyclingCompanyNameFlag = true
				// this.level1Modal.companyNameFlag = false
				this.getCompanyList()
			}
		},
		cancel() {
			this.$refs['systemFro'].resetFields()
			this.forceRefresh = new Date().getTime()
		},
		async getCompanyList() {
			console.log(this.queryCompanyData, 'this.queryCompanyData')

			let data = (await SiteApi.getCompanylist(this.queryCompanyData))
				.data
			if (data.length > 0) {
				const result = data.map(item => ({
					value: item.id,
					label: item.companyName
				}))
				this.level1Modal.companyOptions = result
				// console.log(
				// 	this.level1Modal.companyOptions,
				// 	'this.this.level1Modal.companyOptions'
				// )
			}
			if (data.length == 0) {
				this.level1Modal.formData.companyId = ''
				this.level1Modal.companyOptions = []
			}
		},
		async getPageList() {
			// this.queryData.provId = this.companyData.provId
			// this.queryData.cityId = this.companyData.cityId
			// this.queryData.distId = this.companyData.distId
			// this.queryData.strtId = this.companyData.strtId
			// this.queryData.commId = this.companyData.commId
			// this.queryData.comminId = this.companyData.comminId
			this.queryData.companyId = this.companyData.id
			console.log(this.queryData, '1111111111111111111111')
			let data = (await SiteApi.getPageList(this.queryData)).data
			this.list.data = data.list
			this.queryData.limit = data.pageSize
			this.queryData.page = data.pageNum
			this.queryData.totalRecord = data.totalRecord
			// this.queryData.siteName = ''
			console.log(this.list.data, 'this.list.datathis.list.data')
		},
		postData() {
			let that = this
			console.log(this.level1Modal.formData, '111111111111111111111111')
			console.log(that.queryData.comminId, 'that.queryData.comminId')

			this.$refs['systemFro'].validate(valid => {
				if (valid) {
					if (!that.level1Modal.formData.id) {
						if (
							that.queryData.comminId == null ||
							that.queryData.comminId == '' ||
							that.queryData.comminId == undefined
						) {
							that.$Message.error('请重新选择地址,请精确到小区')
						} else {
							// 添加
							console.log(
								this.level1Modal.formData,
								'2222222222222222'
							)
							SiteApi.add(that.level1Modal.formData).then(res => {
								if (res.data) {
									that.$Message.success('添加成功')
									that.level1Modal.modal1 = false
									that.queryData.provId = undefined
									that.queryData.cityId = undefined
									that.queryData.distId = undefined
									that.queryData.strtId = undefined
									that.queryData.commId = undefined
									that.queryData.comminId = undefined
									that.getPageList()
									that.forceRefresh = new Date().getTime()
									this.$refs['systemFro'].resetFields()
									return
								} else {
									that.$Message.error(res.message)
								}
							})
						}
					} else if (that.level1Modal.formData.id) {
						//修改
						// this.$Message.success('修改成功')
						console.log(this.level1Modal.formData, '3333333333333')
						// setTimeout(() => {
						// 	this.$refs['systemFro'].resetFields()
						// }, 1000)
						//修改
						SiteApi.update(that.level1Modal.formData).then(res => {
							if (res.code == 0) {
								that.$Message.success('修改成功')
								that.level1Modal.modal1 = false
								that.queryData.provId = undefined
								that.queryData.cityId = undefined
								that.queryData.distId = undefined
								that.queryData.strtId = undefined
								that.queryData.commId = undefined
								that.queryData.comminId = undefined
								that.getPageList()
								that.forceRefresh = new Date().getTime()
								this.$refs['systemFro'].resetFields()
								that.level1Modal.formData = {}

								return
							} else {
								that.$Message.error(res.message)
							}
						})
					}
				} else {
					this.$Message.error('请填写完整的表单项')
				}
			})
		},
		//地区赋值
		childByValue(data) {
			this.level1Modal.formData.provId = data.provid || ''
			this.level1Modal.formData.cityId = data.cityid || ''
			this.level1Modal.formData.distId = data.distid || ''
			this.level1Modal.formData.strtId = data.strtid || ''
			this.level1Modal.formData.commId = data.commid || ''
			this.level1Modal.formData.comminId = data.comminid || ''
			this.queryData.provId = data.provid || ''
			this.queryData.cityId = data.cityid || ''
			this.queryData.distId = data.distid || ''
			this.queryData.strtId = data.strtid || ''
			this.queryData.commId = data.commid || ''
			this.queryData.comminId = data.comminid || ''
			this.queryCompanyData.provId = data.provid || ''
			this.queryCompanyData.cityId = data.cityid || ''
			this.queryCompanyData.distId = data.distid || ''
			this.queryCompanyData.strtId = data.strtid || ''
			this.queryCompanyData.commId = data.commid || ''
			this.queryCompanyData.comminId = data.comminid || ''
			console.log(
				this.level1Modal.formData.provId,
				this.level1Modal.formData.cityId,
				this.level1Modal.formData.distId,
				this.level1Modal.formData.strtId,
				this.level1Modal.formData.commId,
				this.level1Modal.formData.comminId
			)
		},
		childCopyByValue(data) {
			// this.level1Modal.formData.provId = data.provid || ''
			// this.level1Modal.formData.cityId = data.cityid || ''
			// this.level1Modal.formData.distId = data.distid || ''
			// this.level1Modal.formData.strtId = data.strtid || ''
			// this.level1Modal.formData.commId = data.commid || ''
			// this.level1Modal.formData.comminId = data.comminid || ''
			// this.queryData.provId = data.provid || ''
			// this.queryData.cityId = data.cityid || ''
			// this.queryData.distId = data.distid || ''
			// this.queryData.strtId = data.strtid || ''
			// this.queryData.commId = data.commid || ''
			// this.queryData.comminId = data.comminid || ''
			// this.queryCompanyData.provId = data.provid || ''
			// this.queryCompanyData.cityId = data.cityid || ''
			// this.queryCompanyData.distId = data.distid || ''
			// this.queryCompanyData.strtId = data.strtid || ''
			// this.queryCompanyData.commId = data.commid || ''
			// this.queryCompanyData.comminId = data.comminid || ''
			// console.log(
			// 	this.level1Modal.formData.provId,
			// 	this.level1Modal.formData.cityId,
			// 	this.level1Modal.formData.distId,
			// 	this.level1Modal.formData.strtId,
			// 	this.level1Modal.formData.commId,
			// 	this.level1Modal.formData.comminId
			// )
		},
		// 修改弹层
		showUpdateModal(row) {
			console.log(row, 'row111111111111111111111111111111')
            this.getProvince(row.commId, row.comminId)
			this.addressFlag = false
			this.level1Modal.modal1 = true
			this.level1Modal.title = '编辑站点信息'
			this.level1Modal.formData = {
				id: row.id,
				siteName: row.siteName,
				siteAddress: row.siteAddress,
				companyId: row.companyId ? row.companyId : '',
				companyName: row.companyName ? row.companyName : '',
				contacts: row.contacts ? row.contacts : '',
				phone: row.phone,
				mobile: row.mobile,
				state: row.state ? Number(row.state) : '',
				provId: row.provId ? row.provId : '',
				cityId: row.cityId ? row.cityId : '',
				distId: row.distId ? row.distId : '',
				strtId: row.strtId ? row.strtId : '',
				commId: row.commId ? row.commId : '',
				comminId: row.comminId ? row.comminId : ''
			}
			console.log(
				this.level1Modal.formData,
				'this.level1Modal.formData1111111111111111111111111'
			)
			// this.level1Modal.companyOptions = [
			// 	{
			// 		value: row.companyId ? row.companyId : '',
			// 		label: row.companyName ? row.companyName : ''
			// 	}
			// ]
			this.queryCompanyData.provId = row.provId
			this.queryCompanyData.cityId = row.cityId
			this.queryCompanyData.distId = row.distId
			this.queryCompanyData.strtId = row.strtId
			this.queryCompanyData.commId = row.commId
			this.queryCompanyData.comminId = row.comminId
			console.log(this.queryCompanyData, '33333333333333333333')
			if (
				this.queryCompanyData.provId &&
				this.queryCompanyData.cityId &&
				this.queryCompanyData.distId &&
				this.queryCompanyData.strtId &&
				this.queryCompanyData.commId &&
				this.queryCompanyData.comminId
			) {
				console.log('111111111')
				// this.level1Modal.recyclingCompanyNameFlag = true
				// this.level1Modal.companyNameFlag = false
				// this.getCompanyList()
			}
			// this.level1Modal.companyNameFlag = true
		},
		// 删除
		delData(row) {
			this.$Modal.confirm({
				title: '确认删除',
				content:
					'<p>您确认删除id为 <strong>' +
					row.id.toString() +
					'</strong> 的 <strong>' +
					row.siteName.toString() +
					'</strong> 网点吗?</p><p>删除后将无法撤销，请谨慎操作！</p>',
				loading: true,
				onOk: () => {
					SiteApi.del(row.id).then(res => {
						this.$Modal.remove()
						if (res.code == 0) {
							this.$Notice.success({
								title: '删除成功'
							})
							this.queryData.page = 1
							this.getPageList()
						} else {
							this.$Notice.error({
								title: res.message
							})
						}
					})
				}
			})
		},
		//回收站点管理员弹层
		showSiteModal(row) {
			this.levelSiteModal.modal = true
			this.levelSiteModal.formData = row
			this.levelSiteModal.flag = true
			console.log(
				this.levelSiteModal.formData,
				'this.levelSiteModal.formData'
			)
		},
		//回收网点定位弹层
		// showSiteLocationModal(row){
		//     this.levelSiteLocationModal.modal = true
		//     this.levelSiteLocationModal.formData = row
		//     this.levelSiteLocationModal.flag = true
		//     console.log(this.levelSiteLocationModal.formData,'this.levelSiteLocationModal.formData')
		// }
		showSiteLocaltionModal(row) {
			console.log(row, 'row')
			this.levelSiteLocaltionModal.modal = true
			this.levelSiteLocaltionModal.formData = row
			this.levelSiteLocaltionModal.flag = true
		},
		// 分页
		changePage(page) {
			this.queryData.page = page
			this.getPageList()
		},
		changePageSize(pageSize) {
			this.queryData.limit = pageSize
			this.getPageList()
		}
	}
}
</script>
<style scoped>
</style>
